import { createApp } from 'vue'
//import './style.css'
import App from './App.vue'
import router from './index'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css' 
import * as ElementPlusIconsVue from '@element-plus/icons-vue';
import { createPinia } from 'pinia';
// main.js 或入口文件
const checkAndFixStorage = () => {
  ['token', 'user'].forEach(key => {
    try {
      const value = localStorage.getItem(key)
      if (value === 'undefined') {
        localStorage.removeItem(key)
        console.warn(`已清理无效的 ${key} 存储`)
      }
    } catch (error) {
      console.error(`存储检查失败 (${key}):`, error)
    }
  })
}

// 在创建 Vue 实例前调用
checkAndFixStorage()
const app = createApp(App)
app.use(router); // 使用路由
app.use(createPinia())
app.mount('#app');
app.use(ElementPlus);
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component);
  }
